#include<stdio.h>
#include<conio.h>
#define FILEINP "CHANGE.INP"
#define FILEOUT "CHANGE.OUT"
char s1[20000],s2[20000];
int arr1[20000]={0},arr2[20000]={0};
int index1[20000]={0},index2[20000]={0};
int n1=0,n2=0,i,j,flag=0;
int dich[20000][20000]={0};
int di[20000][20000];
void input(){
    FILE *fp=fopen(FILEINP,"r");
    fscanf(fp,"%s%s",s1,s2);
    fclose(fp);
}
void createArray(){
    for(i=0;s1[i]!='\0';i++){
        if(s1[i]>='A'){
            if(flag<0){
                n1++;
                index1[n1]=i;
            }
            flag=1;
            arr1[n1]++;
        }else{
            if(flag>0){
                n1++;
                index1[n1]=i;
            }
            flag=-1;
            arr1[n1]--;
        }
    }
    flag=0;
    for(i=0;s2[i]!='\0';i++){
        if(s2[i]>='A'){
            if(flag<0){
                n2++;
                index2[n2]=i;
            }
            flag=1;
            arr2[n2]++;
        }else{
            if(flag>0){
                n2++;
                index2[n2]=i;
            }
            flag=-1;
            arr2[n2]--;
        }
    }
    n1++;n2++;
    int sailech;
    for(i=0;i<n1;i++)
        for(j=0;j<n2;j++){
            
        }
}
long check(int i,int j){
    int a,b;
    
}
int process(){
    long t;
    for(i=0;i<n2;i++)
        for(j=0;j<n1;j++){
            t=check(i,j);
            if(t>0)return t;
        }
    return 0;
}
void output(long n){
    FILE *fp=fopen(FILEOUT,"w");
    fprintf(fp,"%ld",n);
    fclose(fp);
}
int main(){
    input();
    getch();
    return 0;
}
